package org.zizi.dao;

import java.util.List;

import org.zizi.modal.InlandRevenueOrg;

public class InlandRevenueOrgDaoImpl extends BaseDao implements InlandRevenueOrgDao
{
	public void addOrUpdateInlandRevenueOrg(InlandRevenueOrg org) throws Exception
	{
		InlandRevenueOrg t = getInlandRevenueOrg(org.getCode());
		if (t == null)
			esql.helper().insert(org, "t_inland_revenue_org", null, null);
		else
			esql.helper().update(org, "t_inland_revenue_org", null, "code", "code=?", org.getCode());
	}

	public InlandRevenueOrg getInlandRevenueOrg(String code) throws Exception
	{
		return esql.helper().query(InlandRevenueOrg.class, "t_inland_revenue_org", null, null, "code=?", code);
	}

	public List<String> getManagingInlandRevenueOrgCode(String code) throws Exception
	{
		InlandRevenueOrg org = getInlandRevenueOrg(code);
		if (org == null) return null;
		
		return esql.helper().list(String.class, "t_inland_revenue_org", "code", null, null, "relation_code like ?", org.getRelationCode() + "%");
	}
}
